<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="cw" uri="/widget-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>富文本框</title>
		<cw:base></cw:base>
		<script type="text/javascript">
			function submitFormWithHtmlEditor(){
				Wonders.utils.formSubmit(Ext.getCmp("submitHtmlEditorBtn"), 'formWithHtmlEditor',
					function(form,action){
						var json = Ext.decode(action.response.responseText).result[0];
						Wonders.Msg.info("保存成功！",'提示',function(){Ext.getCmp('submitHtmlEditorBtn').enable();__WSSIP_GENERATE_GUID__();});
						return false;
					},
					null,
					function(form,action){
						Ext.getCmp('submitHtmlEditorBtn').enable();
						__WSSIP_FAILURE_HANLDER__(form,action);
						return false;
					}
				);
			}
			
			function loadFormWithHtmlEditor(){
				Wonders.utils.formLoad('formWithHtmlEditor',
			    	'${pageContext.request.contextPath}/demoform/loadFormWithHtmlEditor.action',
			    	{},
			    	function(form,action){
			    		var json = Ext.decode(action.response.responseText).result[0];
			    		Ext.getCmp("_HTMLEditor").setValue(json.messageContext);
			    	}
			    );
			}
		</script>
	</head>
	<body>
		<br>
		<cw:form id="formWithHtmlEditor" ajax="true" url="${pageContext.request.contextPath}/demoform/submitFormWithHtmlEditor.action" waitMsg="提交中...">
			<table>
				<tr>
					<td>
						富文本框：
					</td>
					<td>
						<%-- 高版本浏览器下不兼容
						<cw:htmlEditor id="htmlEditor" property="htmlEditor" label="富文本框" height="200" width="565" 
							uploadUrl="${pageContext.request.contextPath}/oamail/uploadImg.action?funcCode=SYS000020" />--%>
							
						<div id="_HTMLEditor_div"></div>
					</td>
					<td>
						<cw:button id="loadHtmlEditorBtn" text="远程加载" onclick="loadFormWithHtmlEditor();" />
					</td>
					<td>
						<cw:text id="messageContext" property="messageContext" type="hidden"></cw:text>
						<cw:button id="submitHtmlEditorBtn" text="保存" onclick="submitFormWithHtmlEditor();" />
					</td>
				</tr>
			</table>
		</cw:form>
		<cw:theme></cw:theme>
		<script type="text/javascript">
			Ext.onReady(function(){
				var _HTMLEditorObj = new cf_f.HtmlEditor({
					contextId:"messageContext",
					id:"_HTMLEditor",
					name:"_HTMLEditor",
					width:565,
					height:200,
					fieldLabel:"富文本框",
					tabIndex:0,
					uploadUrl:"/widgetCenterGuangdong/oamail/uploadImg.action?funcCode=SYS000020",
					renderTo:"_HTMLEditor_div"
				});
				formWithHtmlEditor_items.push(_HTMLEditorObj);
				resetHeight("htmlEditorFrame");
			})
		
			function resetHeight(frame) {
				var ifm = parent.document.getElementById(frame);
				var obj = document.body;
				var oStyle = obj.currentStyle? obj.currentStyle : window.getComputedStyle(obj, false);
				var initHeight = parseInt(document.body.clientHeight+parseInt(oStyle["margin-top"])+parseInt(oStyle["margin-bottom"]));
				ifm.height = parseInt(initHeight);
			}
		</script>
	</body>
</html>
